<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    *{
      margin:0;
      padding:0;

    }
    #box1{
        width:200px;
        height: 200px;
        background: #ff0000;
        position: absolute;
        left:50%;
        top:50%;
        transform: translate(-50%,-50%);
    }
    #box2{
        width:200px;
        height: 200px;
        background: #ff0000;
        position: absolute;
        left:50%;
        top:50%;
        margin-left: -100px;
        margin-top: -100px;
        /* margin值为宽度的一半 */
    }
    #box3{
        width:200px;
        height: 200px;
        background: #ff0000;
        position: absolute;
        left:0;
        top:0;
        right:0;
        bottom:0;
        margin: auto;
    }
    #box4{
            height:800px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #ff0000;
    }
    #box4 div{
        width:600px;
        height: 600px;
        background-color: #0f0;
    }
    #box5{
        display: table-cell;
        text-align: center;
        vertical-align: middle;
        width:200px;
        height: 200px;
        background: #ff0000;
        /* //div里面的垂直，水平居中 */
    }
    #box6{
        position: relative;
        width:400px;
        height: 160px;
        background: #ff0000;
    }
    #box6 div{
        position: absolute;
        width:200px;
        height: 50px;
        left:calc((400px - 200px)/2);
        top:calc((160 - 50px)/2);
    }
    </style>
</head>
<body>
    <!-- <div id="box1">我是盒子1</div> -->
    <!-- <div id="box2">我是盒子2</div> -->
    <!-- <div id="box3">我是盒子3</div> -->
    <!-- <div id="box4">
        <div>我是盒子4</div>
    </div> -->
    <!-- <div id="box5">我是盒子5</div> -->
    <div id="box6">
            <div>我是盒子6</div>
    </div>
</body>
</html>